<?php

/**
 * SpecItemsModel 模型
 * Class SpecItemsModel
 */
class SpecItemsModel extends BaseModel
{

    public $tableName = "spec_items";
    public $errMsg = '';

    static private $_singleton;

    public function __construct()
    {
        parent::__construct($this->tableName);
    }

    static public function getSingleton()
    {
        if (!self::$_singleton) {
            self::$_singleton = new static();
        }

        return self::$_singleton;
    }

    public function add($data)
    {
        try {
            $selfModel = static::getSingleton();
            return $selfModel->insert([
                'cat_id'        => $data['cat_id'],
                'product_id'    => $data['product_id'],
                'item_name'     => $data['item_name'],
                'create_time'   => isset($data['create_time'])? $data['create_time']: time()
            ]);
        } catch (Exception $e) {
            $this->errMsg = $e->getMessage();
            return false;
        }
    }


}